package cn.jobstart.service.impl;

import cn.jobstart.common.BeanUtils;
import cn.jobstart.vo.ResumeCertificateDetailDomainVO;
import cn.jobstart.vo.ResumeCertificateMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import cn.jobstart.modelExt.ResumeCertificateExt;
import cn.jobstart.dao.IResumeCertificateDao;
import cn.jobstart.searchExt.ResumeCertificateSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeCertificateService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;
import java.util.stream.Collectors;


/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeCertificateService      证书
 */
@Service(value = "resumeCertificateService")
@Slf4j
public class ResumeCertificateServiceImpl extends AbstractBaseService<ResumeCertificateExt, ResumeCertificateSearchExt, String> implements IResumeCertificateService {

    @Resource(name = "resumeCertificateDao")
    private IResumeCertificateDao resumeCertificateDao;

    @Override
    public IBaseDao<ResumeCertificateExt, ResumeCertificateSearchExt, String> getDao() {
        return resumeCertificateDao;
    }

    /**
     * 得到列表
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeCertificateExt> getListByResumeId(String resumeId) {
        if (StringUtil.isNullOrEmpty(resumeId)) {
            return null;
        }

        try {
            return getAllList(ResumeCertificateSearchExt.getInstance().setResumesIdEq(resumeId));
        } catch (SkException e) {
            return null;
        }
    }

    /**
     * @param resumeId
     * @return
     */
    @Override
    public String getCertificateStrByResumeId(String resumeId) {


        try {


            List<ResumeCertificateExt> certificateList = getListByResumeId(resumeId);
            return StringUtil.getJsonArrayStrByList(certificateList, ResumeCertificateMiniDomainVO.class);


        } catch (Exception e) {

        }
        return "";
    }
}